package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.anno.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enums.AutoFillType;
import com.sky.vo.DishPageQueryItemVO;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {
    // @Insert("insert into dish(name, category_id, price, image, description, status, create_time, update_time, create_user, update_user)values (#{name},#{categoryId},#{price},#{image},#{description},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    @AutoFill(type = AutoFillType.INSERT)
    void insert(Dish dish) ;

    Page<DishPageQueryItemVO> page(DishPageQueryDTO dto);
    @Select("select id, name, category_id, price, image, description, status, create_time, update_time, create_user, update_user from dish where id=#{id}")
    Dish selectById(Long id);
    @Delete("delete from dish where id=#{id}")
    void deleteById(Long id);

    void update(Dish dish);
    @Select("select * from dish where category_id=#{categoryId}")
    List<Dish> selectBycategoryId(Long categoryId);

    List<DishVO> seleteByCategoryId(Long categoryId);
}
